package com.bl.weilan.dao.repository;

import com.bl.weilan.dao.model.EmployeeEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by liangweikang on 2018/1/6.
 */
public interface UserRepository extends JpaRepository<EmployeeEntity, String> {

    List<EmployeeEntity> findByMobile(String mobile);

    @Query(value = "select * from employee where if(?1 !='',id=?1,1=1) and if(?2 !='',mobile=?2,1=1)" +
            "and if(?3 !='',name=?3,1=1) and if(?4 !='',status=?4,1=1) ORDER BY create_time DESC \n#pageable\n",
            countQuery ="select * from employee where if(?1 !='',id=?1,1=1) and if(?2 !='',mobile=?2,1=1) and if(?3 !='',name=?3,1=1) and if(?4 !='',status=?4,1=1)",
            nativeQuery = true)
    Page <EmployeeEntity>  findMultList(String id, String mobile, String name , String status, Pageable pageable );


}
